 /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.ipo.mm.ejb.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author makcro
 */
@Entity
@Table(name = "CITY")
@NamedQueries({
    @NamedQuery(name = "City.findAllD", query = "SELECT c FROM City c"),
    @NamedQuery(name = "City.findAll", query = "SELECT c FROM City c WHERE c.deleted = false order by c.name"),
    @NamedQuery(name = "City.findById", query = "SELECT c FROM City c WHERE c.id = :id AND c.deleted = false"),
    @NamedQuery(name = "City.findByName", query = "SELECT c FROM City c WHERE c.name = :name"),
    @NamedQuery(name = "City.findByNote", query = "SELECT c FROM City c WHERE c.note = :note"),
    @NamedQuery(name = "City.findByDeleted", query = "SELECT c FROM City c WHERE c.deleted = :deleted"),
    @NamedQuery(name = "City.findByZipCode", query = "SELECT c FROM City c WHERE c.zipCode = :zipCode")})
public class City implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "Name")
    private String name;
    @Column(name = "Note")
    private String note;
    @Basic(optional = false)
    @Column(name = "Deleted")
    private boolean deleted;
    @Basic(optional = false)
    @Column(name = "ZipCode")
    private String zipCode;
    @OneToMany(mappedBy = "city")
    private Collection<Institution> institutionCollection;
    @JoinColumn(name = "User", referencedColumnName = "Username")
    @ManyToOne(optional = false)
    private User user;

    public City() {
    }

    public City(Integer id) {
        this.id = id;
    }

    public City(Integer id, String name, boolean deleted, String zipCode) {
        this.id = id;
        this.name = name;
        this.deleted = deleted;
        this.zipCode = zipCode;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public String getZipCode() {
        return zipCode;
    }

    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    public Collection<Institution> getInstitutionCollection() {
        return institutionCollection;
    }

    public void setInstitutionCollection(Collection<Institution> institutionCollection) {
        this.institutionCollection = institutionCollection;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof City)) {
            return false;
        }
        City other = (City) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.ipo.mm.ejb.entities.City[id=" + id + "]";
    }

}
